<template>
  <div class="swiper-container" id="floor1Swiper" ref="cur">
    <div class="swiper-wrapper">
      <div
        class="swiper-slide"
        v-for="(carousel, index) in list"
        :key="carousel.id"
      >
        <img :src="carousel.imgUrl" />
      </div>
    </div>
    <!-- 如果需要分页器 -->
    <div class="swiper-pagination"></div>

    <!-- 如果需要导航按钮 -->
    <div class="swiper-button-prev"></div>
    <div class="swiper-button-next"></div>
  </div>
</template>

<script>
import Swiper from "swiper";
export default {
  name: "Carousel",
  props: ["list"],
  watch: {
    list: {
      immediate: true,
      handler() {
        this.$nextTick(() => {
          new Swiper(this.$refs.cur, {
            spaceBetween: 30, //每一屏之间的距离
            speed: 1500, //屏的切换速度
            loop: true, //循环轮播
            autoplay: {
              //自动轮播配置
              delay: 2000, //轮播间隔
              disableOnInteraction: false, //鼠标操作后，是否禁用自动轮播
            },
            pagination: {
              el: ".swiper-pagination", //小圆点容器
              clickable: true, //小圆点是否可以点击
            },
            navigation: {
              nextEl: ".swiper-button-next", //下一张按钮的选择器
              prevEl: ".swiper-button-prev", //上一张按钮的选择器
            },
          });
        });
      },
    },
  },
};
</script>

<style>
</style>